<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <style>
        html,
        body,
        #container {
            width: 100%;
            height: 100%;
            margin: 0px;
            font-size: 13px;
        }

        #pickerBox {
            position: absolute;
            z-index: 9999;
            top: 50px;
            right: 30px;
            width: 300px;
        }

        #pickerInput {
            width: 200px;
            padding: 5px 5px;
        }

        #poiInfo {
            background: #fff;
        }

        .amap_lib_placeSearch .poibox.highlight {
            background-color: #CAE1FF;
        }

        .amap_lib_placeSearch .poi-more {
            display: none !important;
        }
    </style>
    <title>位置经纬度 + 获取货车规划数据</title>
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
    <script type="text/javascript">
        window._AMapSecurityConfig = {
            securityJsCode: '8bb928e25f8e2b4744e9bf1bdb177f77',
        }
    </script>
    <script
        src="https://webapi.amap.com/maps?v=1.4.11&key=66d4a9f6818ad73625a29c9ce3170196&plugin=AMap.TruckDriving"></script>

</head>

<body>
    <div id="container"></div>
    <div id="pickerBox">
        <input id="pickerInput1" placeholder="输入起始地点" />
        <input id="pickerInput2" placeholder="输入目的地点" />
        <button onclick="showLine()">搜索</button>
    </div>
    <script>
        var geocoder = new AMap.Geocoder({
            //   city: '010', //城市设为北京，默认：“全国”
        })
        function showLine() {
            if ($('#pickerInput1').val() && $('#pickerInput2').val()) {
                fun()
                let pickerInput1 = $('#pickerInput1').val()
                let pickerInput2 = $('#pickerInput2').val()
                geocoder.getLocation(pickerInput1, function (status, result) {
                    if (status === 'complete' && result.geocodes.length) {
                        let lnglat = result.geocodes[0].location
                        jcfd = lnglat.lng
                        wcfd = lnglat.lat
                    } else {
                        log.error('根据地址查询位置失败')
                    }
                })
                geocoder.getLocation(pickerInput2, function (status, result) {
                    if (status === 'complete' && result.geocodes.length) {
                        let lnglat = result.geocodes[0].location
                        jmdd = lnglat.lng
                        wmdd = lnglat.lat
                        //fun2()
                    } else {
                        log.error('根据地址查询位置失败')
                    }
                })
            } else {
                alert('请输入出发点和目的地')
            }
        }
    </script>
</body>

</html>